home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / networking / otstreamlogviewer / logengine / logengine.h < prev    next >
Encoding:
Text File  |  2000-06-23  |  4.1 KB  |  121 lines

  1. /*
  2.     File:        LogEngine.h
  3.  
  4.     Contains:    The core code to talk to the STREAMS log module.
  5.  
  6.     Written by: Quinn "The Eskimo!"    
  7.  
  8.     Copyright:    Copyright © 1998-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 7/23/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23.  
  24. /////////////////////////////////////////////////////////////////////
  25. // Pick up toolbox "Files.h", which is needed
  26. // to make OpenTptClient.h compile.
  27. #pragma once
  28. #include <Files.h>
  29.  
  30. /////////////////////////////////////////////////////////////////////
  31. // Pick up low-level OT APIs.
  32.  
  33. #include <OpenTptClient.h>
  34. #include <strlog.h>
  35.  
  36. /////////////////////////////////////////////////////////////////////
  37. // Core Data Structure
  38.  
  39. enum {
  40.     kMagicValue = 'Bing'
  41. };
  42.  
  43.  
  44. struct LogEntry{
  45.     OTLink *fNext;
  46.     OSType fMagic;                // Must be kMagicValue
  47.     UInt32 fRefCount;
  48.     UInt32 fTextLength;
  49.     struct log_ctl fLogHeader;
  50.     // variable length text goes here
  51. };
  52. typedef struct LogEntry                    LogEntry;
  53. typedef struct LogEntry*                LogEntryPtr;
  54.  
  55. extern pascal void RetainLogEntry(LogEntry* thisEntry);
  56.     // Increments the reference count for the log entry.
  57.     // Clients can call this function to hold on to log
  58.     // entries that are passed to them by ForEachNewLogEntry.
  59.     //
  60.     // Context: SystemTask /only/
  61.     
  62. extern pascal void ReleaseLogEntry(LogEntry* thisEntry);
  63.     // Decrements the reference count for the log entry,
  64.     // and frees the entry if count decrements to zero.
  65.     // Clients should eventually call this function to free
  66.     // any log entry they have retained.
  67.     //
  68.     // Context: SystemTask /only/
  69.  
  70. /////////////////////////////////////////////////////////////////////
  71.  
  72. extern pascal OSStatus StartLogging(Boolean logErrors,
  73.                                 UInt32 traceInfoCount, struct trace_ids traceInfo[]);
  74.     // Tells the module to start logging.  If logErrors is true,
  75.     // the log will contain all strlog messages that have the
  76.     // SL_ERROR bit in the flags when they are created.  If
  77.     // traceInfoCount is non-zero, then we're also logging
  78.     // traces.  traceInfo must point to an array of trace_ids
  79.     // that describe which traces we're interested in.  Each
  80.     // trace_id contains a field for module ID, for stream ID,
  81.     // and for level.  Each field specifies the value of that
  82.     // parameter we accept, or -1 to accept any value for that
  83.     // parameter.  For example, the mid field is the module ID
  84.     // whose traces we should accept, or -1 if you want to accept
  85.     // traces for all modules.
  86.     //
  87.     // Context: SystemTask /only/
  88.  
  89. extern pascal void StopLogging(void);
  90.     // Stops the logging process.  Call this if and only if
  91.     // StartLogging returns noErr.  After stopping logging
  92.     // you should call ForEachNewLogEntry to get any log
  93.     // entries that might have accumulated in the time
  94.     // between you making the StopLogging call and the time
  95.     // that logging actually stops.
  96.     //
  97.     // Context: SystemTask /only/
  98.  
  99. extern pascal Boolean LoggingActive(void);
  100.     // Returns whether logging is currently active.
  101.     //
  102.     // Context: SystemTask /only/
  103.  
  104. extern pascal UInt32 NumberOfDroppedLogEntries(void);
  105.     // Returns the number of log entries that have been
  106.     // dropped due to memory constaints.  This should
  107.     // always be zero.
  108.     //
  109.     // Context: SystemTask /only/
  110.  
  111. typedef pascal void (*ProcessLogEntryProcPtr)(LogEntry* logEntry, void *refCon);
  112.  
  113. extern pascal void ForEachNewLogEntry(ProcessLogEntryProcPtr doThis, void *refCon);
  114.     // This routine calls the supplied doThis routine for each
  115.     // log entry that has arrived since the last time you called
  116.     // this routine.  The log entry is immediately released
  117.     // after doThis returns, so you should call RetainLogEntry
  118.     // if you keep a reference to it.
  119.     //
  120.     // Context: SystemTask /only/
  121.